FROM nginx

LABEL maintainer="zhu.xiaohui@e-ports.com"

# 指定工作目录
RUN mkdir -p /www

ADD /ad-portal /www
ADD /node_modules.zip /www
ADD /conf/nginx.conf /etc/nginx/nginx.conf
ADD /conf/default.conf /etc/nginx/conf.d/default.conf
ADD /logs/error.log /var/log/nginx/error.log

WORKDIR /www

# 安装zip命令
RUN apt-get update
RUN apt-get install zip -y
RUN apt-get install wget -y
RUN apt-get install tar -y
RUN apt-get install xz-utils -y
RUN unzip node_modules.zip

# 设置环境变量和端口
ENV EP_ENV development
ENV EP_PORT 9010

RUN wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz
RUN xz -d node-v10.15.3-linux-x64.tar.xz
RUN tar -xvf node-v10.15.3-linux-x64.tar
RUN ln -s /www/node-v10.15.3-linux-x64/bin/node /usr/local/bin/node
RUN ln -s /www/node-v10.15.3-linux-x64/bin/npm /usr/local/bin/npm
RUN node -v
RUN npm -v

# 安装依赖
# RUN npm install adui-domain --registry=http://npm.e-ports.com
# RUN npm install adui-reducer --registry=http://npm.e-ports.com
# RUN npm install epimmutable --registry=http://npm.e-ports.com
# RUN npm install --registry=https://registry.npm.taobao.org

# 构建dist
RUN npm run build

# 配置系统变量，指定端口
ENV PORT 9010

# 将端口9010开放
EXPOSE 9010

# 指定开启镜像立刻执行
# daemon off;是为了防止容器跑着跑着挂掉
ENTRYPOINT nginx -g "daemon off;"